* Replication script for
* "Ideological Alignment and Committee Chair Appointment"
* published in Legislative Studies Quarterly
* authors: Jochen Rehmert & Naofumi Fujimura

* Script replicates:
* Tables: 2, 7 to 12

* Script needs:
* ChaiR_stata2.dta

* directory
cd "..."

* load data
use ChaiR_stata2.dta, clear

*--------------- Setup for MP Random Effects Logit Models ---------------* 	
encode(cabinet), gen(cabinet_id)
 * declare multilevel data 
mi xtset pid  

 
******************************************************************
* Table 2: Ideological Alignment and Committee Chair Appointment *
******************************************************************
 *NB: results may differ marginally in each run due to
 * random weighting of imputed cases
*--------------- Models ---------------* 	
* --- all committees --- *
* (1)
mi estimate, post: xtlogit chair i.session female age term  zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if  party_en == "LDP" & gov == 1 ,  vce(cluster pid) 
est store re_all_1
* (2)
mi estimate, post: xtlogit chair i.session female age term  zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if  party_en == "LDP" & gov == 1  ,  vce(cluster pid) 
est store re_all_2

* --- high policy committees --- *
* (1)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_1
* (2)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2

* --- foreign policy committees --- *
* (1)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1
* (2)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_2

* --- distributive committees --- *
* (1)
mi estimate, post: xtlogit chair_dist i.session female age term exp_dist zombie no_faction pr_only ln_pop dist_cab_pc1_ldp   if party_en == "LDP" & gov == 1 , vce(cluster pid) 
est store re_dist_1
* (2)
mi estimate, post: xtlogit chair_dist i.session female age term exp_dist zombie no_faction pr_only ln_pop dist_cab_pc2_ldp  if party_en == "LDP" &  gov == 1 , vce(cluster pid) 
est store re_dist_2

* export table
esttab  re_all_1 re_all_2 re_hp_1 re_hp_2 re_fp_1 re_fp_2 re_dist_1 re_dist_2,  se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 



******************************************************************
* Table 7: Ideological Alignment and Committee Chair Appointment *
******************************************************************
* --- all committees --- *
* (1)
mi estimate, post: logit chair i.session female age term  zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if  party_en == "LDP" & gov == 1 ,  vce(cluster pid) 
est store log_all_1
* (2)
mi estimate, post: logit chair i.session female age term  zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if  party_en == "LDP" & gov == 1  ,  vce(cluster pid) 
est store log_all_2
 
* --- high policy committees --- *
* (1)
mi estimate, post: logit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store log_hp_1
* (2)
mi estimate, post: logit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store log_hp_2

* --- foreign policy committees --- *
* (1)
mi estimate, post: logit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store log_fp_1
* (2)
mi estimate, post: logit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store log_fp_2

* --- distributive committees --- *
* (1)
mi estimate, post: logit chair_dist i.session female age term exp_dist zombie no_faction pr_only ln_pop dist_cab_pc1_ldp   if party_en == "LDP" & gov == 1 , vce(cluster pid) 
est store log_dist_1
* (2)
mi estimate, post: logit chair_dist i.session female age term exp_dist zombie no_faction pr_only ln_pop dist_cab_pc2_ldp  if party_en == "LDP" &  gov == 1 , vce(cluster pid) 
est store log_dist_2

* export table
esttab  log_all_1 log_all_2 log_hp_1 log_hp_2 log_fp_1 log_fp_2 log_dist_1 log_dist_2 ,  se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 



***************************************************
* Table 8: Controlling for Mainfaction Membership *
***************************************************
gen main_faction = PMsfaction + SGsfaction
* --- high policy committees --- *
* (1)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie 	 pr_only ln_pop PMsfaction dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_ldp_pmfaction
* (2)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie      pr_only ln_pop SGsfaction dist_cab_pc2_ldp  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_ldp_sgfaction
* (3)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie 	 pr_only ln_pop main_faction dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_ldp_mainfaction
* --- foreign policy committees --- *
* (1)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_high zombie   pr_only ln_pop PMsfaction dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_ldp_pmfaction 
* (2)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_high zombie   pr_only ln_pop SGsfaction dist_cab_pc1_ldp  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_ldp_sgfaction
* (3)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_high zombie   pr_only ln_pop main_faction dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_ldp_mainfaction 
 
esttab re_hp_2_ldp_pmfaction re_hp_2_ldp_sgfaction re_hp_2_ldp_mainfaction re_fp_1_ldp_pmfaction re_fp_1_ldp_sgfaction re_fp_1_ldp_mainfaction  ,  se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 


*******************************************************************************
* Table 9: Robustness Checks controlling for various Seniority specifications *
*******************************************************************************
*------ squared seniority ------ *
 * --- high policy committees --- *
mi estimate, post: xtlogit chair_high i.session female age c.term##c.term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if  party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_squared
* --- foreign policy committees --- *
mi estimate, post: xtlogit chair_foreign i.session female age c.term##c.term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if  party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_squared
 

*------ no first timer ------ *
* --- high policy committees --- *
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if term >= 2 & party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_no1st
* --- foreign policy committees --- *
mi estimate, post: xtlogit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if term >= 2 & party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_no1st

*------ no first & second timer ------ *
* --- high policy committees --- *
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if term >= 3 & party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_no2nd

* --- foreign policy committees--- *
mi estimate, post: xtlogit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if term >= 3 & party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_no2nd


*------ no first, second & third timer ------ *
* --- high policy committees --- *
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if term >= 4 & party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_no3rd

* --- foreign policy committees --- *
mi estimate, post: xtlogit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if term >= 4 & party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_no3rd

* export table

esttab  re_hp_2_squared re_fp_1_squared  re_hp_2_no1st re_fp_1_no1st re_hp_2_no2nd  re_fp_1_no2nd  re_hp_2_no3rd re_fp_1_no3rd, se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 




*************************************
* Table 10: High Salience Committee *
*************************************

* ---- high salience committee ---- *
* (1)
mi estimate, post: xtlogit chair_salient i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_salience
* (2)
mi estimate, post: xtlogit chair_salient i.session female age term exp_high zombie no_faction pr_only ln_pop dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_1_salience

esttab  re_hp_2_salience re_hp_1_salience , se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 




**********************************************
* Table 11: Distance from Legislative Median *
**********************************************

* --- high policy committees --- *
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_pm_pc2 if   party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_pm

* --- foreign policy committees --- *
mi estimate, post: xtlogit chair_foreign i.session female age term exp_foreign zombie no_faction pr_only ln_pop dist_pm_pc1 if   party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_pm

* export table
esttab re_hp_2_pm re_fp_1_pm , se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 




**********************************************
* Table 12: Distance from Legislative Median *
**********************************************
* --- high policy committees --- *
* (1)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median2 dist_cab_pc2_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_leg_median
* (2)
mi estimate, post: xtlogit chair_high i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median2  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_hp_2_leg_median_net


* --- foreign policy committees --- *
* (1)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median1 dist_cab_pc1_ldp if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_leg_median
* (2)
mi estimate, post: xtlogit chair_foreign i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median1  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_fp_1_leg_median_net

* --- distributve committees --- *
* (1)
mi estimate, post: xtlogit chair_dist i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median2  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_dist_2_leg_median
* (2)
mi estimate, post: xtlogit chair_dist i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median1  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_dist_1_leg_median

* --- other committees --- *
* (1)
mi estimate, post: xtlogit chair_other i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median2  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_other_2_leg_median
* (2)
mi estimate, post: xtlogit chair_other i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median1  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_other_1_leg_median

* --- all committees --- *
* (1)
mi estimate, post: xtlogit chair i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median2  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_all_2_leg_median
* (2)
mi estimate, post: xtlogit chair i.session female age term exp_high zombie no_faction pr_only ln_pop dist_leg_median1  if party_en == "LDP" & gov == 1, vce(cluster pid)  
est store re_all_1_leg_median

esttab re_all_2_leg_median re_all_1_leg_median re_dist_2_leg_median re_dist_1_leg_median re_other_2_leg_median  re_other_1_leg_median , se star(* 0.1 ** 0.05 *** 0.01) stats (N aic) 

